package com.pro.h5case.front.controller;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pro.h5case.common.controller.BaseController;
import com.pro.h5case.common.model.BRecommend;
import com.pro.h5case.common.service.BRecommendService;

@Controller
@RequestMapping("/recommend")
public class RecommendController extends BaseController{
	@Autowired
	BRecommendService bRecommendService;
	
	@RequestMapping(value="/addRec.html",method=RequestMethod.POST)
	public @ResponseBody void insertRecommend(HttpServletRequest request,BRecommend bRecommend){
		
		
		if (bRecommend.getRecH5Url().getBytes().length>200) {
			logger.info("there too long RecUrl");
		}else if(bRecommend.getRecH5Title().getBytes().length>60){
			logger.info("there too long RecTitle");
		}else if(bRecommend.getRecName().getBytes().length>20){
			logger.info("there too long RecName");
		}else if(bRecommend.getRecPhone().getBytes().length>60){
			logger.info("there too long RecPhone");
		}else{
			bRecommend.setRecCreateTime(new Date());
			bRecommend.setRecDeleteState((byte) 1);
			
			bRecommendService.insertBRecommend(bRecommend);
		}
	}
}
